import http from "../request.js";
// 查询全部消息列表
export function getMessagesList(customerId, startCreatedAt, endCreatedAt, nick, pageNum, pageSize) {
	return http({
		url: '/admin/onlineCustomerService/getMessagesList?customerId=' + customerId + '&startCreatedAt=' +
			startCreatedAt + '&endCreatedAt=' +
			endCreatedAt + '&nick=' +
			nick + '&pageNum=' +
			pageNum + '&pageSize=' +
			pageSize,
		method: "GET"
	})
}
// 获取聊天记录
export function getChatHistory(lastId, pageSize, receiverId, userId) {
	return http({
		url: '/admin/onlineCustomerService/getChatHistory?lastId=' + lastId + '&pageSize=' +
			pageSize + '&receiverId=' +
			receiverId + '&userId=' +
			userId,
		method: "GET",
	})
}
// 发送消息
export function sendMessage(data) {
	return http({
		url: '/admin/onlineCustomerService/sendMessage',
		method: "POST",
		data: data
	})
}
// 查询全部常用语
export function getAllCommonPhrases(pageNum, pageSize) {
	return http({
		url: '/admin/commonphrase/getAllCommonPhrases?pageNum=' + pageNum + '&pageSize=' + pageSize,
		method: "GET",
	})
}
// 新增常用语
export function createCommonPhrase(data) {
	return http({
		url: '/admin/commonphrase/createCommonPhrase',
		method: "POST",
		data
	})
}
// 删除常用语
export function deleteCommonPhrase(id) {
	return http({
		url: '/admin/commonphrase/deleteCommonPhrase?id=' + id,
		method: "DELETE",
	})
}
// 根据id获取常用语
export function getCommonPhraseById(id) {
	return http({
		url: '/admin/commonphrase/getCommonPhraseById?id=' + id,
		method: "GET",
	})
}
// 更新常用语
export function updateCommonPhrase(id, data) {
	return http({
		url: '/admin/commonphrase/updateCommonPhrase/' + id,
		method: "PUT",
		data: data,
	})
}
//查看所有模版问题和答案
export function getAllQuestionTemplates(page, pageSize, appType) {
	return http({
		url: '/admin/onlineService/getAllQuestionTemplates?page=' + page + '&pageSize=' + pageSize +
			'&appType=' + appType,
		method: "GET",
	})
}
// 创建模版
export function createQuestionTemplate(data) {
	return http({
		url: '/admin/onlineService/createQuestionTemplate',
		method: "POST",
		data: data
	})
}
// 删除
export function deleteQuestionTemplate(id) {
	return http({
		url: '/admin/onlineService/deleteQuestionTemplate?id=' + id,
		method: "DELETE",
	})
}
// 编辑
export function updateQuestionTemplate(id, data) {
	return http({
		url: '/admin/onlineService/updateQuestionTemplate/' + id,
		method: "PUT",
		data: data
	})
}
// 查看
export function getQuestionTemplateById(id) {
	return http({
		url: '/admin/onlineService/getQuestionTemplateById?id=' + id,
		method: "GET",
	})
}

export function markMessagesAsRead(chatId, receiverId) {
	return http({
		url: '/admin/onlineCustomerService/markMessagesAsRead?chatId=' + chatId + '&receiverId=' + receiverId,
		method: "GET",
	})
}